package com.oto.model;

import java.io.Serializable;
import java.util.Date;

import javax.jdo.annotations.IdGeneratorStrategy;
import javax.jdo.annotations.IdentityType;
import javax.jdo.annotations.PersistenceCapable;
import javax.jdo.annotations.Persistent;
import javax.jdo.annotations.PrimaryKey;

import com.google.appengine.api.datastore.Text;

/**
 * @author xueqiang.mi
 * @since 2010-12-19
 */
@PersistenceCapable(table = "Message", identityType = IdentityType.APPLICATION)
public class LogDO implements Serializable {
	private static final long serialVersionUID = 6631507427360181717L;

	@PrimaryKey
	@Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
	private Long id;

	@Persistent
	private int type;

	@Persistent
	private Text content;
	@Persistent
	private int result;
	@Persistent
	private Date crtDate;

	public LogDO() {
	}

	public LogDO(int type, String content) {
		this.type = type;
		this.content = new Text(content);
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		LogDO other = (LogDO) obj;
		if (crtDate == null) {
			if (other.crtDate != null)
				return false;
		} else if (!crtDate.equals(other.crtDate))
			return false;
		if (id == null) {
			if (other.id != null)
				return false;
		} else if (!id.equals(other.id))
			return false;
		if (result != other.result)
			return false;
		if (type != other.type)
			return false;
		return true;
	}

	public Text getContent() {
		return content;
	}

	public Date getCrtDate() {
		return crtDate;
	}

	public Long getId() {
		return id;
	}

	public int getResult() {
		return result;
	}

	public int getType() {
		return type;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((crtDate == null) ? 0 : crtDate.hashCode());
		result = prime * result + ((id == null) ? 0 : id.hashCode());
		result = prime * result + this.result;
		result = prime * result + type;
		return result;
	}

	public void setContent(String content) {
		this.content = new Text(content);
	}

	public void setContent(Text content) {
		this.content = content;
	}

	public void setCrtDate(Date crtDate) {
		this.crtDate = crtDate;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public void setResult(int result) {
		this.result = result;
	}

	public void setType(int type) {
		this.type = type;
	}

	@Override
	public String toString() {
		return "MessageDO [id=" + id + ", type=" + type + ", content=" + content + ", result=" + result + ", crtDate="
				+ crtDate + "]";
	}
}
